package com.ss;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/** * Servlet implementation class LoginServlet */ 
public class LoginServlet extends HttpServlet { 

public void doGet(HttpServletRequest request, HttpServletResponse response) 
throws ServletException, java.io.IOException {
try 
{

UserBean user = new UserBean(); 
user.setUserName(request.getParameter("Username")); 
user.setPassword(request.getParameter("Password"));
user = UserDAO.login(user); 
if (user.isValid())
{ 

	HttpSession session = request.getSession(true); 
	session.setAttribute("currentSessionUser",user); 
	response.sendRedirect("userLogged.jsp"); //logged-in page 
} 
	else 
		response.sendRedirect("invalidLogin.jsp"); //error page
} 

catch (Throwable theException) 
{ 
	System.out.println(theException); 
	} 
	
	} 

} 